﻿using Abp.Authorization;
using AbpProjectTemplate.Components.Authorization;
using System.Linq;

namespace AbpProjectTemplate.Application
{
    /// <summary>
    /// 应用验证器
    /// </summary>
    public class AppAuthorizeAttribute : AbpAuthorizeAttribute
    {
        /// <summary>
        /// permissions可传入任意的枚举及字符串进行验证
        /// 枚举将使用<see cref="PermissionHelper.GetPermissionName(object)"/>获取权限名称
        /// 如果此枚举未定义在AppPermissions中，需要自定义处理权限验证逻辑
        /// </summary>
        public AppAuthorizeAttribute(params object[] permissions)
            : base(permissions.Select(t => PermissionHelper.GetPermissionName(t))
                              .ToArray())
        {

        }
    }
}
